package com.jason.java.lib;

import java.lang.ref.SoftReference;

/**
 * @description: ReferenceTest
 * @author: ChenBaoYang
 * @createDate: 2022/2/10 11:20 上午
 */
public class ReferenceTest {

    public static void main(String[] args) {
        String name = "AA";
        SoftReference<String> soft = new SoftReference<String>(name);
        // 必须把强引用对象处理掉，才能只剩下软引用1个
        name = null;
        // 然后通过 get 我们可以从软银用中拿到这个对象
        String name2 = soft.get();
        System.out.println("name = "+name2);
    }
}
